﻿@model TCM.Course
@{
    ViewBag.Title = "Edit";
}

@using (Html.BeginForm())
{
    
    @Html.ValidationSummary(true)     

    <table style="width: 99.9%">
        <tr>
            <td class="IndexBack">
                @Html.ActionLink(" ", "Index")</td>
            <td style="text-align: right">
                <span class="FormTitle">@Html.DisplayFor(model => model.Name)</span></td>
        </tr>
    </table>
    
     
    <div class="toolbar">
        <input type="submit" value="Save" class="submit" />
       @* @if (Model != null)
        {
            if (Model.CourseID != null)nda
            {                
                <input type="button" value="Generate Agenda" onclick="location.href='@Url.Action("GenerateScheduleCourse/" + Model.CourseID.ToString(), "Course")'" />
            }
        }*@

    </div> 

   
    
        
    <div class="HiddenFor">
        @Html.HiddenFor(x => x.CourseID)
    </div>
    
    <div class="NavSubMenu">
        <span class="SubMenu_Title">Course...</span>

        <div class="SubMneu">
            <a href="#" id="Information" onclick="changeMenu(this.id)" class="SubMenuActive">
                <span class="NavSubMenu_Title">Information</span>
                <span class="NavSubMenu_Body">General Information Course</span>
            </a>
        </div>
        <div class="SubMneu">
            <a href="#" id="Schedule" onclick="$('.timepicker input').timepicker();changeMenu(this.id);">
                <span class="NavSubMenu_Title">Schedule</span>
                <span class="NavSubMenu_Body">Course Schedule Information</span>
            </a>
        </div>
        
        <div class="SubMneu">
            <a href="#" id="Students" onclick="changeMenu(this.id);">
                <span class="NavSubMenu_Title">Students</span>
                <span class="NavSubMenu_Body">Regestered Students</span>
            </a>
        </div>

        <div class="SubMneu">
            <a href="#" id="Grades" onclick="changeMenu(this.id);">
                <span class="NavSubMenu_Title">Grades</span>
                <span class="NavSubMenu_Body">Student Final Grade Results</span>
            </a>
        </div>
        
    </div>
    
    <div class="ContentSubMenu"></div>

        <div id="tabInformation" class="SubMenuContent active">
            <span class="SubMenu_Title">Information</span>
            <fieldset>
                <legend></legend>
                <ol>
                   
                     <li class="editor-label">
                        @Html.LabelFor(model => model.SubjectID)

                        @Html.DropDownListFor(model => model.SubjectID, (SelectList)ViewBag.SelectedListSubjects, string.Empty)
                    </li>
                    <li class="editor-label">
                        @Html.LabelFor(model => model.LevelID)

                        @Html.DropDownListFor(model => model.LevelID, (SelectList)ViewBag.SelectListLevels, string.Empty)
                    </li>
                  

                    <li class="editor-label">
                        @Html.LabelFor(model => model.InstructorID, "Instructor")

                        @Html.DropDownListFor(x => x.InstructorID, (SelectList)ViewBag.SelectListInstructors, string.Empty)
                        @Html.ValidationMessageFor(model => model.InstructorID)
                    </li>

                   

                    <li class="editor-label">
                        @Html.LabelFor(model => model.RoomID, "Room")

                        @Html.DropDownListFor(x => x.RoomID, (SelectList)ViewBag.SelectListRooms, string.Empty)
                        @Html.ValidationMessageFor(model => model.RoomID)
                    </li>

                    <li class="editor-label">
                        @Html.LabelFor(model => model.ExFromDate)

                        @Html.TextBoxFor(model => model.ExFromDate, new { @class = "datepicker" })
                        @Html.ValidationMessageFor(model => model.ExFromDate)
                    </li>

                    <li class="editor-label">
                        @Html.LabelFor(model => model.ExToDate)

                        @Html.TextBoxFor(model => model.ExToDate, new { @class = "datepicker" })
                        @Html.ValidationMessageFor(model => model.ExToDate)
                    </li>

                

                   
                    <li class="OneColumn OneColumn">
                        @Html.LabelFor(model => model.Notes)

                        @Html.TextAreaFor(model => model.Notes)
                        @Html.ValidationMessageFor(model => model.Notes)
                    </li>

                </ol>
            </fieldset>
        </div>

        <div id="tabSchedule" class="SubMenuContent">
            <span class="SubMenu_Title">Schedule</span>

            <div class="toolbar">
                <input id="addAnother" type="button" value="New Appointment" />
            </div>
            <br />
            <div style="width:800px; float:right;">
            <table id="grdSchedule" class="grdTable" style="width: 100%;" cellspacing="0">
                <thead>
                    <tr class="GridHeader">
                        <th>From Time</th>
                        <th>To Time</th>
                        <th>Week Day</th>
                        <th>Delete</th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model != null)
                    {
                        if (Model.CourseSchedules != null)
                        {
                            foreach (var line in Model.CourseSchedules)
                            {
                        <tr>
                            @Html.Partial("EditRelatedCourseSchedule", line)
                        </tr>
                            }
                        }
                    }
                </tbody>
            </table>
                </div>

        </div>

     <div id="tabStudents" class="SubMenuContent">
            <span class="SubMenu_Title">Schedule</span>
              
            <div class="toolbar">
               @Html.Awe().MultiLookupFor(s=>s.students).Parent(o=>o.SubjectID,"SubjectID").SearchUrl(Url.Action("SearchRegistrants","studentsMultiLookup"))
               

            </div>
            <br />
           
              
             

        </div>

        @*<div id="tabAgenda" class="SubMenuContent ">
            <span class="SubMenu_Title">Agenda</span>
            <div class="toolbar">
                <input id="addAnotherAgenda" type="button" value="New Appointment" />
            </div>
            <br />
            <table id="grdAgenda" class="grdTable" style="width: 100%;">
                <thead>
                    <tr class="GridHeader">
                        <th>Start Date Time</th>
                        <th>Enda Date Time</th>
                        <th>...</th>
                    </tr>
                </thead>
                <tbody>
                    @if (Model != null)
                    {
                        if (Model.Agenda != null)
                        {

                            foreach (var item in Model.Agenda)
                            {
                        <tr>
                            @Html.Partial("_RelatedAgenda", item)
                        </tr>
                            }
                        }
                    }
                </tbody>
            </table>

        </div>

        *@

         
         <div id="tabGrades" class="SubMenuContent">
            <span class="SubMenu_Title">Grades</span>

            <div class="toolbar">
                
            </div>
            <br />
            ----------

        </div>
    @*</div>*@
}

        
        
<script lang="javascript" type="text/javascript">

    function GenerateAgenda(){

    }

    $(function () 
    {
        $("#addAnother").sortable();
        
        $("#addAnother").click(function () {
          
            $.get('/Course/EditRelatedCourseSchedule?courseid5=@Model.CourseID.ToString()', function (template) {
               
                ///remove tr which is came by partial view because 
                ///this tr tag come after input which makes a problem whith flexigrid 
                /// so after deleting this tr tag , i enter it again to include input that 
                /// is come first 
                var temp1 = template.toString().replace("<tr>", "");

                temp1 = temp1.toString().replace("</tr>", "");

                var rhtml = "<tr>" + temp1 + "</tr>";

                ///append to flexigrid               
                $("#grdSchedule tbody tr:first").before(rhtml);

                ///recall the timepicker function after adding the new html tags.
                $('.timepicker input').timepicker();
            });
        });
     
        $("#addAnotherAgenda").click(function () {

            $.get('/Course/_NewRelatedAgenda', function (template) {

                ///remove tr which is came by partial view because 
                ///this tr tag come after input which makes a problem whith flexigrid 
                /// so after deleting this tr tag , i enter it again to include input that 
                /// is come first 
                var temp1 = template.toString().replace("<tr>", "");

                temp1 = temp1.toString().replace("</tr>", "");

                var rhtml = "<tr>" + temp1 + "</tr>";

                ///append to flexigrid               
                $("#grdAgenda tbody tr:first").before(rhtml);

                
            });
        });
    });

    $(document).ajaxStart(function () {
        // debugger;
        $("#spinner").show();//text("Triggered ajaxStart handler.");
    });
    $(document).ajaxComplete(function () {
        // debugger;
        $("#spinner").hide(100);//text("Triggered ajaxStart handler.");
    });
    

</script>
<style type="text/css">
    .DataGrid .timepicker div {
        position: relative;
    }

    .grdTable .timepicker div input {
    }

    .grdTable .timepicker img {
        position: absolute;
        top: 9px;
        right: -34px;
        width: 16px !important;
        height: 17px !important;
    }

    .loader {
        position: absolute!important;
        margin-top: 35px!important;
    }
</style>

 